<?php

namespace app\index\controller;

use app\common\YujisoController;

class Common extends YujisoController
{
    public function __construct()
    {
        parent::__construct();
    }
    //获取sku信息
    public function getSku(){
        $skuInfo=\app\common\service\SkuService::getBatchInfoBySku($this->param['sku'],['ean','cnname','enname','weighting_price']);
        returnJson(1,'',empty($skuInfo)?[]:$skuInfo[$this->param['sku']]);
    }
     //获取sku信息
    public function getSkuByWarehouse(){
        $temp=[];
        $ware=\app\common\ConfigBase::getinStockPrice();
        $skuInfo=\app\common\service\SkuService::getBatchInfoBySku($this->param['sku'],['cnname']);
        
        $available_stock=isset($ware[$this->param['warehouse_id']."_".$this->param['sku']]) ? $ware[$this->param['warehouse_id']."_".$this->param['sku']]['available_stock'] : 0;
        $price=isset($ware[$this->param['warehouse_id']."_".$this->param['sku']]) ? $ware[$this->param['warehouse_id']."_".$this->param['sku']]['wam'] : 0;
        
        $temp['sku_name']=$skuInfo[$this->param['sku']]['cnname']??'';
        $temp['price']=$price;
        $temp['available_stock']=$available_stock;
        returnJson(1,'',$temp);
    }
}
